﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2017_01_22_Massive_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("Please enter an integer number!");
            //int input;
            //try
            //{
            //    input = Int32.Parse(Console.ReadLine());
            //}
            //catch
            //{
            //    Console.WriteLine("Invalid input!");
            //}
            //IncrementByTen(input);
            //SumNumbers(input);

            //FindDistance(1, 1, 5, 4);
            //Console.WriteLine("Enter integer X!");
            //int x = Int32.Parse(Console.ReadLine());
            //Console.WriteLine("Enter integer Y!");
            //int y = Int32.Parse(Console.ReadLine());
            //DefineQuarter(x, y);

            DrawBorders(8, 16, 'X');//height, length, char
            
            CountEven();
        }

        //static public bool ValidateInput(int input)
        //{
        //    try
        //    {
        //        input = Int32.Parse(Console.ReadLine());
        //        return;
        //    }
        //}

        static void IncrementByTen(int input)
        {
            Console.WriteLine(input + 10);
        }

        static void SumNumbers(int input)
        {
            int sum = 0;
            for (int i = 0; i <= input; i++)
            {
                sum += i; 
            }
            Console.WriteLine(sum);
        }

        static void FindDistance(int x1, int y1, int x2, int y2)
        {
            double distance = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
            Console.WriteLine(Math.Round(distance, 3));
        }

        static void DefineQuarter(int x, int y)
        {
            if (x*y>0)
            {
                if (x > 0)
                {
                    Console.WriteLine("I");
                }
                else
                {
                    Console.WriteLine("III");
                }
            }
            else if (x*y<0)
            {
                if (y > 0)
                {
                    Console.WriteLine("II");
                }
                else
                {
                    Console.WriteLine("IV");
                }
            }
            else
            {
                if (x!=0)
                {
                    Console.WriteLine("On the X axis");
                }
                else if (y!=0)
                {
                    Console.WriteLine("On the Y axis");
                }
                else
                {
                    Console.WriteLine("In the origin of coordinates");
                }
            }
            
        }

        static void DrawBorders(int height, int length, char ch)
        {
            string firstLine = new string(ch, length);
            Console.WriteLine(firstLine);
            StringBuilder intermLine = new StringBuilder();
            intermLine.Append(ch).Append(' ', length - 2).Append(ch);
            for (int i = 1; i < (height - 1); i++)
            {
                Console.WriteLine(intermLine);
            }
            Console.WriteLine(firstLine);
        }

        public static int [] GenerateArray(int size)
        {
            Random rnd = new Random();
            int[] intArr = new int[size];
            for (int i = 0; i < size; i++)
            {
                intArr[i] = rnd.Next(1, 101);
                Console.WriteLine(intArr[i]);
            }
            return intArr;
        }

        static void CountEven()
        {
            int[] myArray = GenerateArray(5);
            int even = 0;
            int odd = 0;
            for (int i = 0; i < myArray.Length; i++)
            {
                if (myArray[i]%2 == 0)
                {
                    even++;
                }
                else
                {
                    odd++;
                }
            }
            Console.WriteLine("Even: {0}\nOdd: {1}", even, odd);
        }
    }
}
